
export default {
	isDebug:0,
	UrlAgreement: 'http',
	UrlCatalog: '/index/contract/',

	GetHost(){
		let host = window.location.host;

		if (host != 'localhost:8080') {
			return host
		}else{
			return 'admin.mumway.com'
		}
		
	},
	isIos(){
		var u = navigator.userAgent;
		var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
		return isiOS ? true : false;
	},
	serverUrl({clearCatalog}){
		let Url = this.UrlAgreement+'://'+ this.GetHost()
		return clearCatalog ? Url : Url+this.UrlCatalog
	},
	GetQueryString(name){
		var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if(r!=null)return  unescape(r[2]); return null;
	},
	checkPhone(phone){ 
		if(!(/^1[345678]\d{9}$/.test(phone))){ 
			return false; 
		} else{
			return true; 
		}
	},
	disposePhone(phone){
		var l = phone.substring(0,3);
		var r = phone.substring(7,11);
		return l + 'xxxx' + r
	},
	intToChinese (str) {
		str = str+'';
		var len = str.length-1;
		var idxs = ['','十','百','千','万','十','百','千','亿','十','百','千','万','十','百','千','亿'];
		var numd = ['零','壹','贰','叁','肆','伍','陆','柒','捌','玖'];
		var num = ['0','一','二','三','四','五','六','七','八','九'];
		return str.replace(/([1-9]|0+)/g,function( $, $1, idx, full) {
			var pos = 0;
			if( $1[0] != '0' ){
				pos = len-idx;
				if( idx == 0 && $1[0] == 1 && idxs[len-idx] == '十'){
					return idxs[len-idx];
				}
				return num[$1[0]] + idxs[len-idx];
			} else {
				var left = len - idx;
				var right = len - idx + $1.length;
				if( Math.floor(right/4) - Math.floor(left/4) > 0 ){
					pos = left - left%4;
				}
				if( pos ){
					return idxs[pos] + num[$1[0]];
				} else if( idx + $1.length >= len ){
					return '';
				}else {
					return num[$1[0]]
				}
			}
		});
	},
	formatDate(date, fmt){
		if (/(y+)/.test(fmt)) {
			fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
		}
		let o = {
			'M+': date.getMonth() + 1,
			'd+': date.getDate(),
			'h+': date.getHours(),
			'm+': date.getMinutes(),
			's+': date.getSeconds()
		}
		for (let k in o) {
			if (new RegExp(`(${k})`).test(fmt)) {
				let str = o[k] + ''
				fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str))
			}
		}
		return fmt
	},
	promotionType(sourcelist, sear){
		let val  = 'SEM推广';
		for (var name in sourcelist){
			if (sear.indexOf(name) != -1) {
				val = sourcelist[name]
			}
		}
		return val
	},
	countDown(){
		
	}


}
